home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Tool Chest / OS⁄Toolbox / DeferCrsr / DeferCrsr.a next >
Encoding:
Text File  |  1990-09-14  |  2.6 KB  |  83 lines  |  [TEXT/MPS ]

  1. ***********************************************************************
  2. ***        
  3. ***        Defer Cursor
  4. ***        This program defers the cursor updating that normally happens
  5. ***        during slot VBL time. Since the cursor updating can take as
  6. ***        long as 900µSec, and holds off other slot interrupts, it is
  7. ***        handy to be able to defer the updating to a more civilized time.
  8. ***        This program replaces the normal jCrsrTask with an RTS, and installs
  9. ***        a VBL task that calls jCrsrTask routine every VBL.
  10. ***        
  11. ***        Since the normal VBLs are a level of interrupt lower than slot
  12. ***        interrupts, the cursor updating will not hold off slot interrupts.
  13. ***        
  14. ***        This is a one way street. A real implementation should restore
  15. ***        the regular jCrsrTask when this scheme is no longer needed.
  16. ***        
  17. ***        
  18. ***        Build commands:
  19. ***
  20. ***        asm DeferCrsr.a -lo DeferCrsr.a.lst -l
  21. ***        link DeferCrsr.a.o -o DeferCrsr
  22. ***
  23. ***********************************************************************
  24.  
  25.                     STRING    ASIS
  26.                     PRINT    OFF
  27.                     INCLUDE 'Traps.a'
  28.                     INCLUDE 'SysEqu.a'
  29.                     PRINT    ON
  30.  
  31. ******************************** Entry *******************************
  32.  
  33. Entry    MAIN
  34.  
  35.         ALIGN 2
  36.         bra.s            Entry2
  37.         
  38. ****************************** MyVBLTask *****************************
  39.  
  40. TaskBegin
  41. MyVBLTask
  42.         
  43.         move.w        #1,vblCount(a0)
  44.         move.l        TaskEnd,a0
  45.         jmp            (a0)
  46.  
  47. ***************************** MyjCrsrTask ****************************
  48.  
  49. MyjCrsrTask
  50.         rts
  51. TaskEnd
  52.  
  53. ******************************** Entry2 ******************************
  54.  
  55. TaskSize    EQU        TaskEnd-TaskBegin
  56. VBLEntry    EQU        TaskSize+4                    ;keep the old jCrsrTask pointer in between the 
  57.                                                 ; tasks and VBLTask record
  58.  
  59. Entry2        
  60.         move.l        #TaskSize+18,d0                ;18 bytes = VBLTask record and a pointer
  61.         _NewPtr        ,SYS,CLEAR                    ;make a block in the system heap
  62.         bne.s        Abort
  63.         move.l        a0,a2                        ;save the pointer
  64.         move.l        a0,a1                        ;a0 = source, a1 = destination
  65.         lea            MyVBLTask,a0                ;now copy the two tasks over
  66.         move.w        #TaskSize,d0
  67.         _BlockMove
  68.         
  69.         move.l        a2,a0                        ;resotore the pointer
  70.         move.l        jCrsrTask,TaskSize(a0)        ;put the system jCrsrTask pointer before the VBL record
  71.         adda.l        #MyjCrsrTask-TaskBegin,a0    ;make a pointer to our jCrsrTask
  72.         move.l        a0,jCrsrTask                ; and install it
  73.         
  74.         adda.l        #VBLEntry,a2                ;now point to the VBLTask Record
  75.         move.w        #vType,qType(a2)            ;look for qType, etc. in AIncludes
  76.         move.l        a1,vblAddr(a2)                ;point to our task
  77.         move.w        #1,vblCount(a2)                ;do it once every VBL
  78.         move.w        #0,vblPhase(a2)                ;no phase
  79.         move.l        a2,a0                        ;a0 must point to VBL task record
  80.         _VInstall
  81.         
  82. abort    _exitToShell                            ;all's well that ends…
  83.         END